import { getStorageItem, setStorageItem } from '@/utils/auth'

const state = {
  routerList: getStorageItem('router')
}

const mutations = {
  SET_ROUTERLIST: (state, data) => {
    state.routerList = data
  }
}

const actions = {
  setRouterList({ commit }, data) {
    return new Promise(resolve => {
      commit('SET_ROUTERLIST', data)
      setStorageItem('router', data)
      resolve()
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
